﻿using System.Text;
using System.Threading.Tasks;
using System;

namespace ArabicToRoman
{
    class ArabicToRoman
    {
        private static string RomanDigits(int arabic, char tens, char fives, char ones)
        {

            if (arabic <= 3)
            {
                return new string(ones, arabic);
            }
            if (arabic == 4)
            {
                return ones.ToString() + fives.ToString();
            }
            if (arabic == 5)
            {
                return fives.ToString();
            }
            if (arabic <= 8)
            {
                return fives + new string(ones, arabic - 5);
            }
            return ones.ToString() + tens.ToString();
        }
        int arabicNumb = int.Parse(Console.ReadLine());
        static void Main(string[] args)
        {

            int arabicNumb = int.Parse(Console.ReadLine());
            // Thousands.   
            string result = "";
            int digit = arabicNumb / 1000;
            arabicNumb = arabicNumb % 1000;
            result += new string('M', digit);
            // Hundreds. 
            digit = arabicNumb / 100;
            arabicNumb = arabicNumb % 100;
            result += RomanDigits(digit, 'M', 'D', 'C');
            // Tens.  
            digit = arabicNumb / 10;
            arabicNumb = arabicNumb % 10;
            result += RomanDigits(digit, 'C', 'L', 'X');
            // Ones.   
            digit = arabicNumb;
            result += RomanDigits(digit, 'X', 'V', 'I');
            Console.WriteLine(result);
        }
    }
}
